import requests


class IndexAPI:
    def inum(self):
        # 登录
        my = {"username": "19515542478", "password": "123456"}
        a = requests.post("http://192.168.124.121:8080/login", data=my)
        # print(a.json())
        # 提取token
        rdata = a.json()
        t = rdata["Admin-Token"]
        # t=rdata.get("Admin-Token")
        token = {"Admin-Token": t}

        # 首页统计
        a = requests.post("http://192.168.124.121:8080/OaBackLog/num", headers=token)
        # print(a.json())

    def oaEvent(self):
        # 登录
        my = {"username": "19515542478", "password": "123456"}
        a = requests.post("http://192.168.124.121:8080/login", data=my)
        # print(a.json())
        # 提取token
        rdata = a.json()
        t = rdata["Admin-Token"]
        # t=rdata.get("Admin-Token")
        token = {"Admin-Token": t}

        # 工作台任务列表
        a = requests.post("http://192.168.124.121:8080/OaRecord/queryTask",headers=token)
        # print(a.json())
        # 工作台当月日
        a = requests.post("http://192.168.124.121:8080/OaRecord/queryEvent", data="month=2023-09", headers=token)
        # print(a.json())

        a = requests.post("http://192.168.124.121:8080/OaRecord/queryEventByDay", data="day=2023-09-26", headers=token)
        # print(a.json())
    def itask(self):
        # 登录
        my = {"username": "19515542478", "password": "123456"}
        a = requests.post("http://192.168.124.121:8080/login", data=my)
        # print(a.json())
        # 提取token
        rdata = a.json()
        t = rdata["Admin-Token"]
        # t=rdata.get("Admin-Token")
        token = {"Admin-Token": t}

        z = {"type": "0", "page": "1", "limit": "15"}
        a = requests.post("http://192.168.124.121:8080/OaRecord/getOaRecordPageList", data=z, headers=token)
        # print(a.json())